home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE01 / CONSTRUC / AGENDA.PAS next >
Encoding:
Pascal/Delphi Source File  |  1995-03-11  |  1.5 KB  |  64 lines

  1. unit Agenda;
  2. interface
  3. uses SysUtils, Classes, StdCtrls, Date, Convert;
  4.  
  5. Type
  6.   TAgenda = class(TMemo)
  7.               private
  8.                 FAgenda: String;
  9.                 FDate:   TDate;
  10.  
  11.               protected
  12.                 procedure SetAgenda(Const FileName: String);
  13.  
  14.               published
  15.                 property Agenda: String read FAgenda write SetAgenda;
  16.  
  17.               public
  18.                 constructor Create(AOwner: TComponent); override;
  19.             end {TAgenda};
  20.  
  21.   procedure Register;
  22.  
  23. implementation
  24.  
  25.   constructor TAgenda.Create(AOwner: TComponent);
  26.   begin
  27.     inherited Create(AOwner);
  28.     ScrollBars := ssVertical; { set vertical scrollbars }
  29.     FDate := TDate.Create(self);
  30.   end {Create};
  31.  
  32.   procedure TAgenda.SetAgenda(Const FileName: string);
  33.   var f: System.Text;
  34.       Str: String;
  35.       FConvert: TConvert;
  36.   begin
  37.     {$I-}
  38.     System.Assign(f,FileName);
  39.     Reset(f);
  40.     if IOResult = 0 then
  41.     begin
  42.       FConvert := TConvert.Create(self);
  43.       FConvert.Decimal := FDate.Year;
  44.       FAgenda := FileName;
  45.       Lines.Clear; { clear contents }
  46.       Lines.Add(FDate.DateString + ' ' + FConvert.Roman);
  47.       Lines.Add('-----');
  48.       while not eof(f) do
  49.       begin
  50.         readln(f,Str);
  51.         if System.Pos(FDate.DateString,Str) = 1 then Lines.Add(Str)
  52.       end;
  53.       FConvert.Destroy;
  54.       System.Close(f)
  55.     end
  56.     {$I+}
  57.   end {SetAgenda};
  58.  
  59.   procedure Register;
  60.   begin
  61.     RegisterComponents('Dr.Bob', [TAgenda])
  62.   end {Register};
  63. end.
  64.